    <div class="site_map" align="left">Trang chủ <img src="/onlinemarket/img/navbit-arrow-right.png"/>khuyến mại</div>
    <div class="heading">
        <div class="heading_left"></div>
        <div class="heading_right"></div>
        <div class="heading_center">
        	<h3>Quản lý Khuyến mại</h3>
        </div>

        <div class="table">
            <h1>&nbsp;</h1>
           <form  method="post" id="Offsale" name="Offsale" action="/onlinemarket/offsales/save">
		    <table style="padding-left: 20px; padding-right: 125px;" class="noborder">
                
		   <input type="hidden" id="id" name="id" value="<?php echo($iOffsale['Offsale']['id']); ?>"/>
                 
                 <tr>
                 <td><font color="red">*</font>Sản Phẩm</td>
				 <td>
					<select name="product_id" style="width:200px; align:center;"> 
						<?php foreach($product as $prod){ ?>
						<option value="<?php echo ($prod['Product']['id']); ?>"><?php echo ($prod['Product']['name']);?></option>
						<?php } ?>
					</select>
				 </td>
				  <td style="width: 50px;">&nbsp;</td>
				   <td>Kiểu khuyến mại </td><td><input type="text" name="type" value="<?php echo($iOffsale['Offsale']['type']); ?>"  /></td>
                 </tr>
                 <tr>
                 	<td><font color="red">*</font>Giá Mới</td><td><input type="text" name="new_price" value="<?php echo($iOffsale['Offsale']['new_price']); ?>"  /></td>
					 <td style="width: 50px;">&nbsp;</td>
					        <td><font color="red">*</font>Ngày Bắt Đầu</td><td><input type="text" name="begin_date" id="begin_date" style="text-align: center;" readonly="true" value="<?php if ($iOffsale['Offsale']['begin_date'] != "") echo(date("Y-m-d", strtotime($iOffsale['Offsale']['begin_date']))); ?>"/></td>
                 </tr>
                 <tr>
                 	<td><font color="red">*</font>Ngày Kết Thúc</td><td><input type="text" name="end_date" id="date" style="text-align: center;" readonly="true" value="<?php if ($iOffsale['Offsale']['end_date'] != "") echo(date("Y-m-d", strtotime($iOffsale['Offsale']['end_date']))); ?>"/></td>
					 <td style="width: 50px;">&nbsp;</td>
					        <td>Mô tả</td><td><input type="text" name="description" value="<?php echo($iOffsale['Offsale']['description']); ?>"  /></td>
                 </tr>
                 <tr>
                                <td><font color="red">*</font>Trạng Thái</td>
                                <td colspan="4">
                                    <select id="status" name="status" style="width:200">
                                        <option value="1" <?php if($iOffsale['Offsale']['status'] == 1) echo('selected="selected"'); ?>>Active</option>
                                        <option value="0" <?php if($iOffsale['Offsale']['status'] == 0) echo('selected="selected"'); ?>>Inactive</option>
                                    </select>
                                </td>
                            </tr>
            	 <tr>
                    <td colspan="5" align="right">
                    <input type="submit" value="Lưu" style="height: 25px; padding-top: 0.3em;"/>
                   <input type="button" value="Hủy" style="height: 25px; padding-top: 0.3em;" onclick="onCancel();"/>
                    </td>
					
                    </tr>
                </table>
				 </td>
                </tr>
                <tr>
                    <td colspan="2" style="padding-bottom: 0;"><hr /></td>
                </tr>
                <tr>
                    <td colspan="2" style="padding-top: 0;">Trường <font color="red">*</font> yêu cầu phải nhập</td>
                </tr>
				
                </table>
            </form>
        </div>
<table class="border" style="width: 100%;">
    <tr>
       				 <td align="right"><a href="/onlinemarket/offsales">Thêm khuyến mại</a></td>
    </tr>
    <tr>
        <th>Sản Phẩm</th>
        <th>Hình Thức Khuyến Mại</th>
        <th>Giá Mới</th>
		<th>Ngày Bắt Đầu</th>
        <th>Ngày Kết Thúc</th>
        <th>Mô tả</th>
        <th>Trạng Thái</th>
		<th>Chức Năng</th>
    </tr>
<?php foreach ($Offsales as $offsale) : ?>
<tr>
	<?php foreach($product as $pro){
		if($pro['Product']['id'] == $offsale['Offsale']['product_id']){ ?>
    <td align=center><?php echo($pro['Product']['name']); } } ?></td>
    <td align=center><?php echo($offsale['Offsale']['type']); ?></td>
    <td align=center><?php echo($offsale['Offsale']['new_price']); ?></td>
    <td align=center><?php echo($offsale['Offsale']['begin_date']); ?></td>
    <td align=center><?php echo($offsale['Offsale']['end_date']); ?></td>
    <td align=center><?php echo($offsale['Offsale']['description']); ?></td>
    <td align=center><?php if($iOffsale['Offsale']['status'] == 1) {echo("Active");}else{echo("Inactive");}  ?></td>
    <td align=center>
        <img style="cursor: pointer;" src="/onlinemarket/img/system/bt_edit.png" onclick="onEdit('/onlinemarket/offsales/index/<?php echo($offsale['Offsale']['id']);?>')" alt="Sửa" title="Sửa"/>
        <img style="cursor: pointer;" src="/onlinemarket/img/system/bt_delete.png" onclick="onEdit('/onlinemarket/offsales/delete/?id=<?php echo($offsale['Offsale']['id']);?>')" alt="Xóa" title="Xóa"/>
    </td>
</tr>
<?php endforeach; ?>
</table>
<div style="text-align: right;">
    <?php echo $this->Paginator->numbers();?>
    <?php echo $this->Paginator->prev('« Previous', null, null, array('class' => 'disabled')); ?>
    <?php echo $this->Paginator->next('Next »', null, null, array('class' => 'disabled')); ?>
</div>
</div>
<script>
function onEdit(link) {
        window.location = link;
    }
    function onCancel() {
        $('form').slideUp('slow');
    }
    function getQueryVariable(variable) {
        var query = window.location.search.substring(1);
        var vars = query.split('&');
        for (var i=0; i<vars.length; i++) {
            var pair = vars[i].split('=');
            if (pair[0] == variable) {
                return pair[1];
            }
        }
    };
	$(document).ready(function() {
        Calendar.setup({
           inputField: "date",
           ifFormat: "%Y-%m-%d",
           daFormat: "%Y-%m-%d",
           timeFormat: "12"
        });
        $("input:submit, input:button").button();
    });
	$(document).ready(function() {
        Calendar.setup({
           inputField: "begin_date",
           ifFormat: "%Y-%m-%d",
           daFormat: "%Y-%m-%d",
           timeFormat: "12"
        });
        $("input:submit, input:button").button();
    });

</script>

</script>

